<!-- 量化 -->
<template>
	<view class="container">
		<!-- 头部 start -->
		<view class="head">
			<home-head @toCenter="toCenter"></home-head>
		</view>

		<view class="tab">
			<u-tabs :list="tabs" :is-scroll="false" :current="current" bg-color="#101334" active-color="#fff"
				inactive-color="aliceblue" height="100" @change="change"></u-tabs>
		</view>
		<swiper id="swiperBox" :style="{ height: swiperHeight + 'px' }" :current="current" @change="tabsChange">
			<swiper-item class="swiper-item" v-for="(pitem, pindex) in tabs" :key="pindex">
				<scroll-view scroll-y style="width: 100%; height: 100%" :refresher-triggered="pitem.triggered">
					<quant-content-1 v-if="current == 0"></quant-content-1>
					<quant-content-2 v-if="current == 1"></quant-content-2>
					<quant-content-3 v-if="current == 2"></quant-content-3>
					<quant-content-4 v-if="current == 3"></quant-content-4>


				</scroll-view>
			</swiper-item>
		</swiper>
		<!-- <u-tabbar :list="tabbarArr" :mid-button="true" bg-color="#101334"></u-tabbar> -->
	</view>
</template>

<script>
	import {mapState,mapMutations} from "vuex";
	import homeHead from '@/components/home/home-head.vue';
	import quantContent1 from '@/components/quantization/quant-content1.vue'
	import quantContent2 from '@/components/quantization/quant-content2.vue'
	import quantContent3 from '@/components/quantization/quant-content3.vue'
	import quantContent4 from '@/components/quantization/quant-content4.vue'
	export default {
		computed:{
			...mapState('tabbar', ['tabbarArr']),
		},
		components: {
			quantContent1,
			quantContent2,
			quantContent3,
			quantContent4,
			homeHead

		},
		data() {
			return {

				// tab
				index: 0,
				swiperHeight: 0,
				tabs: [{
						name: "策略模型",
						triggered: false,
						_triggered: false,
					},
					{
						name: "全部策略",
						triggered: false,
						_triggered: false,
					},
					{
						name: "运行中策略",
						triggered: false,
						_triggered: false,
					},
					{
						name: "利润统计",
						triggered: false,
						_triggered: false,
					},
				],
				current: 0,
				barHeight: 25,
			};
		},
		onLoad(){
			//this.current = 1
			

		},
		mounted() {
			let that = this;
			uni.getSystemInfo({
				success(e) {
					//console.log("success", e);
					let {
						windowWidth,
						windowHeight,
						safeArea
					} = e;
					// console.log('safeArea', safeArea)
					const query = uni.createSelectorQuery().in(that);
					query
						.select("#swiperBox")
						.boundingClientRect((data) => {
							// console.log('safeArea', safeArea, 'data', data)
							that.swiperHeight = safeArea.bottom - data.top;
						})
						.exec();
				},
			});
		},
		onShow() {
			
			let current = uni.getStorageSync('current')
			console.log('current', current)
			this.current = current
			uni.setStorageSync('current',0)
			console.log("onShow");
		},
		methods: {

			//获取系统状态栏高度
			getSystemStatusBarHeight: function() {
				_self = this;
				// #ifdef APP-PLUS
				var height = plus.navigator.getStatusbarHeight();
				_self.barHeight = height;
				// #endif
				// #ifdef H5
				_self.barHeight = 0;
				// #endif
			},
			change(index) {
				this.current = index;
			},
			create() {
				console.log("create");
			},
			tabsChange(e) {
				this.current = e.detail.current;
				//console.log("current", this.current);
			},
			toCenter() {
				this.$emit('toCenter')
			}
		},
	};
</script>
<style lang='scss' scoped>
	.container {
		background-color: #101334;
		min-height: 100vh;

	}

	.head {
		background-color: #101334;
		position: relative;
		top: 0;
		left: 0;
		z-index: 1;
	}

	>>>.u-navbar-inner {
		background-color: #101334;
	}



	// 资产
	.asset {
		display: flex;
		color: aliceblue;
		font-size: 28rpx;
		justify-content: space-between;
	}

	// 现货 合约
	.sticky {
		width: 750rpx;
		height: 50rpx;
		background-color: #101334;
		color: #fff;
		padding: 10rpx 24rpx;
	}

	.cell-box {
		background: #101334;
		padding: 18rpx;

		.icon {
			width: 32rpx;
			height: 32rpx;
			margin-right: 22rpx;
		}
	}

	.cell-box2 {
		background: #101334;
		padding: 18rpx;

		.group {
			display: flex;
			flex-direction: column;

			.item {
				display: flex;
				align-items: center;
				min-height: 100rpx;
				background-color: #151e3d;
				padding: 20rpx 10rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-bottom: 30rpx;
				padding: 0 20rpx;
				border-radius: 20rpx;

				.item-img {
					display: flex;
					align-items: center;
				}

				.strategy-name {
					display: flex;
					align-items: center;
					justify-content: flex-start;
					color: aliceblue;
					font-size: 36rpx;
					font-family: "Microsoft YaHei";
					font-weight: 700;
				}

				.btn-cel {
					display: flex;
					align-items: center;
					justify-content: center;
				}

				.create-btn {
					display: flex;
					width: 100rpx;
					height: 50rpx;
					padding: 10rpx;
					background-color: #d85012;
					color: aliceblue;
					font-size: 24rpx;
				}
			}
		}
	}

	.content {
		color: aliceblue;
		padding-bottom: 100rpx;

		.item-strategy {
			display: flex;
			flex-direction: column;
			background-color: #151e3d;
			border-radius: 20rpx;
			color: #45506e;
			margin: 20rpx;
			padding: 20rpx;

			.item-name {
				margin-bottom: 15rpx;
				font-size: 24rpx;
			}

			.summary {
				display: flex;
				flex-direction: column;
				margin-bottom: 20rpx;

				.row {
					display: flex;
					margin-bottom: 5rpx;
					flex-direction: row;
					justify-content: space-between;

					.strategy-name {
						color: aliceblue;
					}

					.strategy-status {
						color: aqua;

						&.stop {
							color: orangered;
						}
					}

					text {
						text-align: center;
					}

					&.summary-title {
						font-size: 26rpx;
						margin: 10rpx 0 20rpx 0;
					}

					&.summary-content {
						font-size: 24rpx;
						color: aliceblue;

						text {
							display: flex;
							min-width: 80rpx;
							align-items: center;
							justify-content: center;
						}
					}
				}
			}

			.strategy-btn {
				width: 90vw;
				display: flex;
				// align-content: flex-end;
				// align-items: flex-end;
				flex-direction: row;
				justify-content: flex-end;

				.u-btn {
					margin-left: 10rpx;
					margin-right: 0;
				}
			}

			.date {
				color: aliceblue;
				margin-bottom: 10rpx;
			}
		}

		.earn {
			background-color: #c09358;
			width: 94vw;
			min-height: 240rpx;
			margin: 0 auto;
			border-radius: 20rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-around;

			.earn-tab {
				padding: 30rpx 0;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;

				.benefit {
					font-size: 32rpx;
				}
			}
		}

		.earn-item {}
	}
</style>
